package com.ruoyi.performance.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.performance.domain.InfoPrePerformanceEvaluation;
import com.ruoyi.performance.service.IInfoPrePerformanceEvaluationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 事情评估自评Controller
 *
 * @author ruoyi
 * @date 2022-02-24
 */
@RestController
@RequestMapping("/performance/evaluation")
@Api(tags = "事情评估自评")
public class InfoPrePerformanceEvaluationController extends BaseController
{
    @Autowired
    private IInfoPrePerformanceEvaluationService infoPrePerformanceEvaluationService;

    /**
     * 查询事情评估自评列表
     */
//    @PreAuthorize("@ss.hasPermi('performance:evaluation:list')")
    @GetMapping("/list")
    @ApiOperation("查询事情评估自评列表")
    @ApiImplicitParam(name = "infoPrePerformanceEvaluation", value = "实体类", dataType = "InfoPrePerformanceEvaluation")
    public TableDataInfo list(InfoPrePerformanceEvaluation infoPrePerformanceEvaluation)
    {
        startPage();
        List<InfoPrePerformanceEvaluation> list = infoPrePerformanceEvaluationService.selectInfoPrePerformanceEvaluationList(infoPrePerformanceEvaluation);
        return getDataTable(list);
    }

    /**
     * 导出事情评估自评列表
     */
    @PreAuthorize("@ss.hasPermi('performance:evaluation:export')")
    @Log(title = "事情评估自评", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoPrePerformanceEvaluation infoPrePerformanceEvaluation)
    {
        List<InfoPrePerformanceEvaluation> list = infoPrePerformanceEvaluationService.selectInfoPrePerformanceEvaluationList(infoPrePerformanceEvaluation);
        ExcelUtil<InfoPrePerformanceEvaluation> util = new ExcelUtil<InfoPrePerformanceEvaluation>(InfoPrePerformanceEvaluation.class);
        util.exportExcel(response, list, "事情评估自评数据");
    }

    /**
     * 获取事情评估自评详细信息
     */
    @PreAuthorize("@ss.hasPermi('performance:evaluation:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取事情评估自评详细信息")
    @ApiImplicitParam(name = "id", value = "id", dataType = "Long")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(infoPrePerformanceEvaluationService.selectInfoPrePerformanceEvaluationById(id));
    }

    /**
     * 新增事情评估自评
     */
    @PreAuthorize("@ss.hasPermi('performance:evaluation:add')")
    @Log(title = "事情评估自评", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增事情评估自评")
    @ApiImplicitParam(name = "infoPrePerformanceEvaluation", value = "实体类", dataType = "InfoPrePerformanceEvaluation")
    public AjaxResult add(@RequestBody InfoPrePerformanceEvaluation infoPrePerformanceEvaluation)
    {
        return toAjax(infoPrePerformanceEvaluationService.insertInfoPrePerformanceEvaluation(infoPrePerformanceEvaluation));
    }

    /**
     * 修改事情评估自评
     */
    @PreAuthorize("@ss.hasPermi('performance:evaluation:edit')")
    @Log(title = "事情评估自评", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改事情评估自评")
    @ApiImplicitParam(name = "infoPrePerformanceEvaluation", value = "实体类", dataType = "InfoPrePerformanceEvaluation")
    public AjaxResult edit(@RequestBody InfoPrePerformanceEvaluation infoPrePerformanceEvaluation)
    {
        return toAjax(infoPrePerformanceEvaluationService.updateInfoPrePerformanceEvaluation(infoPrePerformanceEvaluation));
    }

    /**
     * 删除事情评估自评
     */
    @PreAuthorize("@ss.hasPermi('performance:evaluation:remove')")
    @Log(title = "事情评估自评", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除事情评估自评")
    @ApiImplicitParam(name = "ids", value = "id", dataType = "Long[]")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(infoPrePerformanceEvaluationService.deleteInfoPrePerformanceEvaluationByIds(ids));
    }
}
